<!DOCTYPE html>
<html lang="en">
<head>
   
    <meta charset="UTF-8">
        
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
        
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>线性渐变</title>
        <style>
        div {
            float: left;
            margin: 30px;
            width: 100px;
            height: 150px;
            border: 2px solid orange;
            font-size: 14px;
            line-height: 1.5;
        }

        .box1 {
            /* 1、属性值最少为两种颜色 */
            background: -webkit-linear-gradient(red, yellow);
            /* Safari 5.1 - 6.0 */
            background: -o-linear-gradient(red, yellow);
            /* Opera 11.1 - 12.0 */
            background: -moz-linear-gradient(red, yellow);
            /* Firefox 3.6 - 15 */
            background: linear-gradient(red, yellow);
            /* 标准的语法 */
        }

        .box2 {
            /* 2、可以设置颜色渐变的方向，比如从左到右 */
            background: -webkit-linear-gradient(left, green, yellow);
            background: -o-linear-gradient(left, green, yellow);
            background: -moz-linear-gradient(left, green, yellow);
            background: linear-gradient(left, green, yellow);
        }

        .box3 {
            /* 3、也可以沿着对角的方向渐变 */
            background: -webkit-linear-gradient(top left, blue, yellow);
            background: -o-linear-gradient(top left, blue, yellow);
            background: -moz-linear-gradient(top left, blue, yellow);
            background: linear-gradient(top left, blue, yellow);
        }

        .box4 {
            /* 4、或者，我们直接用角度确定渐变的方向（12点钟方向为0deg） */
            background: -webkit-linear-gradient(60deg, rgb(248, 182, 44), rgb(0, 159, 233));
            background: -o-linear-gradient(60deg, rgb(248, 182, 44), rgb(0, 159, 233));
            background: -moz-linear-gradient(60deg, rgb(248, 182, 44), rgb(0, 159, 233));
            background: linear-gradient(60deg, rgb(248, 182, 44), rgb(0, 159, 233));
        }

        .box5 {
            /* 5、我们也可以定义多种颜色的渐变，之前的方向的设置方法不变 */
            background: -webkit-linear-gradient(45deg, red, orange, yellow, green, blue, indigo, violet);
            background: -o-linear-gradient(45deg, red, orange, yellow, green, blue, indigo, violet);
            background: -moz-linear-gradient(45deg, red, orange, yellow, green, blue, indigo, violet);
            background: linear-gradient(45deg, red, orange, yellow, green, blue, indigo, violet);
        }

        .box6 {
            /* 6、当然，渐变可以是很多次的 */
            background: -webkit-repeating-linear-gradient(red, red 10%, yellow 20%);
            background: -o-repeating-linear-gradient(red, red 10%, yellow 20%);
            background: -moz-repeating-linear-gradient(red, red 10%, yellow 20%);
            background: repeating-linear-gradient(red, red 10%, yellow 20%);
        }
    </style>
</head>

<body>
        <div class="box1"></div>
        <div class="box2"></div>
        <div class="box3"></div>
        <div class="box4"></div>
        <div class="box5"></div>
        <div class="box6"></div>

</body>

</html>